package pactice_handler

import (
	"peilian-api/app/global/bind"
	"peilian-api/app/global/databases/tables"
	"peilian-api/app/model"
	"peilian-api/app/services"
	"peilian-api/utils/format"

	"github.com/gin-gonic/gin"
)

// 获取面试过程中的聆听视频
func GetVideoUrl(ctx *gin.Context) {
	var tsr model.TypeStrReq
	if err := bind.ShouldBinding(ctx, &tsr); err != nil {
		format.NewResponseJson(ctx).SuccessDataList(0)
		return
	}
	if tsr.Typ != tables.Trealism && tsr.Typ != tables.Tspecial {
		format.NewResponseJson(ctx).SuccessDataList(0)
		return
	}
	out, err := services.GetMerginVideo(tsr.Typ)
	if err != nil {
		format.NewResponseJson(ctx).SuccessDataList(0)
		return
	}
	format.NewResponseJson(ctx).SuccessDataList(len(out), out)
}
